import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-20
 * Time: 15:02
 */
public class Test71 {

    static Stack<Integer> st;
    static Stack<Integer> minStack;

    static class MinStack {

        public MinStack() {
            st = new Stack<>();
            minStack = new Stack<>();
        }

        static public void push(int val) {
            st.push(val);
            if(minStack.isEmpty()) {
                minStack.push(val);
            }else {
                if(minStack.peek() >= val) {
                    minStack.push(val);
                }
            }
        }

        static public void pop() {
            if(st.isEmpty()) {
                return;
            }
            Integer val = st.pop();
            if(minStack.peek().equals(val)) {
                minStack.pop();
            }
        }

        static public int top() {
            return st.peek();
        }

        static public int getMin() {
            return minStack.peek();
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] operations = {"MinStack","push","push","push","getMin","pop","top","getMin"};
        Integer[] params = {null,-2,0,-3,null,null,null,null};
        int n = operations.length;

        MinStack minStack = null;
        Object[] results = new Object[n];

        for (int i = 0; i < n; i++) {
            switch (operations[i]) {
                case "MinStack":
                    minStack = new MinStack();
                    results[i] = null;
                    break;
                case "push":
                    minStack.push(params[i]);
                    results[i] = null;
                    break;
                case "pop":
                    minStack.pop();
                    results[i] = null;
                    break;
                case "top":
                    results[i] = minStack.top();
                    break;
                case "getMin":
                    results[i] = minStack.getMin();
                    break;
                default:
                    results[i] = "Invalid operation";
            }
        }
        for (Object result : results) {
            System.out.print(result == null ? "null" : result);
            System.out.print(" ");
        }
    }

}
